<template>
  <div style="width: 900px">
    <pdf
      :src="url"
      ref="pdfview"
      v-for="i in numPages" 
      :key="i"  
      :page="i"
    />
  </div>
</template>

<script>
import pdf from "vue-pdf";
export default {
  components: { pdf },
  data(){
      return {
          url:'http://localhost:8000/201903261413265995_yangyang14.pdf',
          numPages:''
      }
  },
  mounted(){
      this.getNumPages();
  },
  methods: {
    getNumPages() {
      let loadingTask = pdf.createLoadingTask(this.url);
      loadingTask.promise
        .then((pdf) => {
          this.numPages = pdf.numPages;
        })
        .catch((err) => {
          console.error("pdf 加载失败", err);
        });
    },
  },
};
</script>

<style>
</style>